<div class="popup_body">
    <div class="search">
        <div class="float_right">
            <button class="btn btn_yellow" id="query_${pid}">搜索</button>
        </div>
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td align="right">手机号：</td>
                <td><input type="text" class="text" id="mobile_${pid}"/></td>
            </tr>
        </table>
    </div>
    <div style="width:800px; height:360px; padding-top: 6px;">
        <table id="page_table_${pid}">
        </table>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_red" id="ok_${pid}">确定</button>
    <button class="btn btn_border" id="close_${pid}">关闭</button>
</div>
<script>
    (function() {
        var win = $('#${pid}'), windowData = win.data('windowData');
        var datagrid = $('#page_table_${pid}');
        datagrid.datagrid({
            fit: true,
            width: '100%',
            height: '100%',
            striped: true,
            pagination: true,
            url: "${contextPath}/security/basic/passport/page.htm?agentId=${Session['SESSION_KEY_USER'].agentId}",
            fitColumns: true,
            pageSize: 10,
            pageList: [10, 50, 100],
            idField: 'id',
            singleSelect: true,
            selectOnCheck: false,
            checkOnSelect: false,
            autoRowHeight: false,
            rowStyler: gridRowStyler,
            columns: [
                [
                    {
                        title: 'ID',
                        align: 'center',
                        field: 'id',
                        width: 60
                    },
                    {
                        title: '姓名',
                        align: 'center',
                        field: 'realName',
                        width: 60
                    },
                    {
                        title: '手机号',
                        align: 'center',
                        field: 'mobile',
                        width: 60
                    },
                    {
                        title: '卡号',
                        align: 'center',
                        field: 'cardNo',
                        width: 60
                    },
                    {
                        title: '余额',
                        align: 'center',
                        field: 'balance',
                        width: 60,
                        formatter: function(val) {
                            return new Number(val / 100).toFixed(2);
                        }
                    },
                    {
                        title: '上次登录',
                        align: 'center',
                        field: 'lastLoginTime',
                        width: 60
                    },
                    {
                        title: '是否启用',
                        align: 'center',
                        field: 'isActive',
                        width: 60
                    }
                ]
            ],
            onLoadSuccess:function() {
                datagrid.datagrid('clearChecked');
                datagrid.datagrid('clearSelections');
            }
        });
        $('#ok_${pid}').click(function() {
            var passport = datagrid.datagrid('getSelected');
            if(passport) {
                passport = {
                    id: passport.id, realName: passport.realName,mobile: passport.mobile,balance: passport.balance
                }
                windowData.ok({
                    passport: passport
                });
                win.window('close');
            } else {
                $.messager.alert('提示信息', '请选择姓名和手机号码');
            }

        });
        $('#close_${pid}').click(function() {
            $('#${pid}').window('close');
        });
        $('#query_${pid}').click(function() {
            query();
        });

        function reload() {
            datagrid.datagrid('reload');
            tree.tree('reload')
        }

        function query() {
            datagrid.datagrid('options').queryParams = {
                mobile: $('#mobile_${pid}').val()
            };

            datagrid.datagrid('load');
        }
    })()
</script>


